package handler

import (
	"Gin/Api/request"
	"Gin/global/model"
	"ViewSrv/view"
	context2 "context"
	"github.com/gin-gonic/gin"
	"net/http"
)

func VideoList(context *gin.Context) {
	var VideoListRequest request.VideoListRequest
	if err := context.ShouldBind(&VideoListRequest); err != nil {
		context.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
		return
	}
	list, err := model.ViewClient.VideoList(context2.Background(), &view.VideoListRequest{
		Address: VideoListRequest.Address,
		TypeId:  VideoListRequest.TypeId,
	})
	if err != nil {
		context.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
		return
	}
	context.JSON(http.StatusOK, gin.H{
		"data": list,
		"msg":  "获取成功",
	})
}
